<?php
	$this->load->library('form_validation');
	$autocompleteStatus = 'off'; // 输入框自动填充开关 Debug用
/**
 * Add a new Question 
 *
 * Creates the opening portion of a question's div block. Including the open portion of the div, 
 * the div of the title, validation error msg title, and the open portion of Bootstrap CSS grid div.
 * ps. The title is followed by the validation msg which would be printed if the input is empty.
 *
 * @access	public
 * @param	string	the name of the block
 * @param	array	a key/value pair of attributes(e.g name, id, class etc.)
 * @param	string	the title of the question
 * @param	array	an indexed array of the names of the fields that must input
 * @return	string
 */
	function q_open($name, $attrs = NULL, $q_title, $fields = '') {
		$attributes = '';
		if(!is_null($attrs)) {
			foreach ($attrs as $key => $value) {
					$attributes = $attributes . $key . '="' . $value . '"' . ' ';
			}
		}
		echo '<div class="q-div" name="'.$name.'" '.$attributes.'>';

		echo '<div class="q-title">'.$q_title.q_required($fields).'</div>';
		echo '<div class="row">';
	}

/**
 * Close a Question 
 *
 * Give two </div> to close a question
 *
 * @access	public
 * @return	string
 */
	function q_close() {
		echo '</div>';
		echo '</div>';
	}

/**
 * 建立提示区块
 *
 * 建立问题中的提示和填写示例，使用Boostrap CSS布局和自定义样式，一般为右1/2
 *
 * @access	public
 * @param	string	提示的内容
 * @return	string	填写示例的内容
 */
	function q_help_open($q_help = '', $q_example = '', $long = FALSE, $js = '') {
		if($long == TRUE) {
			echo '<div class="span5 q-help" '.$js.'>';
		}
		else {
			echo '<div class="span4 q-help" '.$js.'>';
		}
		echo $q_help;
		echo '<br>';
		echo '<span class="q-example text-info">'.$q_example.'</span>';
		echo '</div>';
	}

	function _radio_open($name, $radio_sets) {
		foreach ($radio_sets as $key => $value) {
			echo '<label for="'.$name.'_'.$key.'" class="radio"><input class="validate[required]" id="'.$name.'_'.$key.'" type="radio" name="'.$name.'" value="'.$value.'" '
				.set_radio_after_callback($name, $value).'>&nbsp;'.$value.'</label>'."\n";
		}
	}

	function _select_open($name, $option_sets, $default = FALSE) {
		echo '<select class="validate[required] autowidth" name="'.$name.'">'."\n";
		if($default) {
			echo '<option value="" '.set_select($name, '', TRUE).'>请选择</option>';
		}
		foreach ($option_sets as $key => $value) {
			echo '<option value="'.$key.'" '.set_select($name, $key).'>'.$value.'</option>';
		}
		echo '</select>';
	}

	function form_input_appanded_open($input_sets, $app_text) {
		echo form_input($input_sets).'<span class="add-on">'.$app_text.'</span>';
	}

	function form_input_prepend_open($input_sets, $pre_text) {
		echo '<span class="add-on">'.$pre_text.'</span>'.form_input($input_sets);
	}
	function _table_open($theads, $tbody_id) {
		echo '<table class="table table-nonfluid" style="font-size:12px;margin-bottom:0px">';
			echo '<thead>';
				echo '<tr>';
					foreach ($theads as $key => $value) {
						echo '<th>'.$value.'</th>';
					}
				echo '</tr>';
			echo '</thead>';
			echo '<tbody id="'.$tbody_id.'">';
	}

	function _table_close() {
			echo '</tbody>';
		echo '</table>';
	}

	function add_material_question($item_name, $field_name, $optional = TRUE, $with_fee = FALSE) {
		if($with_fee == TRUE) {
			q_open($item_name, NULL, '请填入<b>今年</b> <b>'.$item_name.'</b> 的资金投入');
		}
		else {
			q_open($item_name, NULL, '请填入<b>今年</b>购买 <b>'.$item_name.'</b> 所花费的资金');
		}
		echo '<div class="span4">';
			echo '<div class="input-append" id="'.$field_name.'_div">';
		$input_current_item = array(
			'name' => $field_name,
			'value' => trim(set_value($field_name)),
			'class' => 'input-mini validate[required, min[0], custom[number]]',
			'id' => $field_name."_input",
			'autocomplete' => 'off');
		form_input_appanded_open($input_current_item, '元');
			echo '</div>';
		if($optional = FALSE) {
			echo '</div>';
			q_help_open('提示：只需输入金额的数值即可','填写示例：500'); 
		}
		else {
			echo '<label for="no_input_'.$field_name.'" class="checkbox">'.form_checkbox('no_'.$field_name, '1', FALSE, 'id="no_input_'.$field_name.'"').' 没有'.$item_name.'投入</label>';
			echo '</div>';
			q_help_open('提示：只需输入金额的数值即可<br>如果没有'.(($with_fee == FALSE)?'购买':'投入').$item_name.'，请选中 "没有'.$item_name.'投入"','填写示例：500', FALSE, 'style="margin-bottom:5px;"'); 
		}
		q_close();
	}
	/* 显示验证结果：分为 is_required未填写，logic_error逻辑错误，warning格式警告，outlier异常值 */

	function q_required($field_name) { // 验证后，在标题后加上未填写记号，返回HTML
		$msg_required = '<span style="color:red"><b>*</b></span><span style="font-size:12px;font-style:italic;color:red;margin-left:10px">此题必答</span>';

		/* 验证未填写 */
		if(is_array($field_name)) { // 有多个field
			$flag = 0; // 错误标记
			foreach ($field_name as $key => $value) {
				if(strpos(form_error($value), 'required') != FALSE)
					$flag = 1;
			}
			if($flag == 1)
				return $msg_required; // 置于q-title后	
		}
		else {
			if(strpos(form_error($field_name), 'required') != FALSE) // 未填写
				return $msg_required; // 置于q-title后
		}
	}

	function set_radio_after_callback($field_name, $value) { // 暂时解决callback后不设置radio的bug
		if(isset($_POST[$field_name]) && $_POST[$field_name] == $value)
			return 'checked';
	}
?>

<!DOCTYPE html>
<html lang="zh_CN">
<head>
	<meta charset="utf-8">
	<meta name="renderer" content="webkit|ie-stand">
	<title>成本收益调查问卷</title>
	<link rel="icon" href="favicon.ico" type="image/x-icon">
	<script src="/js/jquery-1.10.1.min.js"></script>
<!-- City Select -->
	<script src="/js/jquery.cityselect.js"></script>
	<script type="text/javascript">
		$(function() {
			$("#administrative").citySelect({
				nodata:"hidden",
				required:false,
				prov:"<? echo set_value('prov'); ?>", 
				city:"<? echo set_value('city'); ?>", 
				dist:"<? echo set_value('dist'); ?>"
			});
		});
	</script>
<!-- Validation Engine -->
	<link rel="stylesheet" href="/css/validationEngine.jquery.css">
	<script src="/js/jquery.validationEngine-zh_CN.js"></script> 
	<script src="/js/jquery.validationEngine.js"></script> 
	<script type="text/javascript">
		jQuery(document).ready(function(){
			// binds form submission and fields to the validation engine
			jQuery("#form_basic").validationEngine({
				binded:false,
				autoPositionUpdate:true,
				autoHidePrompt:true,
				autoHideDelay:6000,
				showOneMessage:true
			});
		});
	</script>
<!-- My JS -->
	<!-- 各页面验证 -->
	<script src="/js/myjs/jquery.validatePage.js"></script>
	<!-- "其它"select与text联动 -->
	<script src="/js/myjs/jquery.otherInput.js"></script>
	<!-- 可选text与checkbox联动 -->
	<script src="/js/myjs/jquery.noInputCheckbox.js"></script>
	<!-- 全页面JS -->
	<script type="text/javascript">
		// 禁用退格键
		document.onkeydown = function(event){var e=event||window.event||arguments.callee.caller.arguments[0]; var d=e.srcElement || e.target; if(e&&e.keyCode==8){return d.tagName.toUpperCase() == 'INPUT' || d.tagName.toUpperCase() == 'TEXTAREA' ? true : false }} 
	</script>
<!-- Bootstrap Form Builder-->
	<link href="/form_builder/assets/css/lib/bootstrap.min.css" rel="stylesheet">

<!-- Custom Style -->
	<link rel="stylesheet" type="text/css" href="/css/survey.css">

</head>
<body>
<div id="container">
	<div id="survey-title">
		<h1 class="header">葡萄成本收益调查问卷</h1>
	</div>
<div id="body">
	<?php 
		$form_attributes = array(
			'id' => 'form_basic',
			'action' => '/survey');
		echo form_open('survey', $form_attributes); 
	?>

<!-- 首页 欢迎页 -->
<div class="page" id="0">
	<div id="banner"></div>
	<div class="q-div">
		<div class="q-title" style="line-height:1.5em">
			<p class="text-center" style="font-weight:bold;margin-bottom:10px">欢迎您参与葡萄生产在线调研！</p>
			<p style="margin-bottom:15px">
				您好，非常感谢您在百忙中抽出宝贵时间进行此次调研！本问卷由国家葡萄产业技术体系编写，用于了解全国范围内的葡萄生产动态，使技术体系的岗位专家更好地开展工作，以惠及更多的葡萄种植者。本次调查的结果仅用作研究用途，我们将对您填写的资料完全保密，并且问卷不会涉及您的个人信息。
			</p>
			<p style="font-size:13px">请您阅读以下<b class="text-info">填写提示</b>，能帮助您顺利地完成此次调研：</p>
				<ol style="font-size:13px">
					<li>为了避免因填写错误而导致您的问卷失效，请尽量<span class="text-info">根据题目和提示准确填写和选择</span>；</li>
					<li>在您点按"下一页"按钮时，系统会对当前页所填的各项信息进行校对，并会提示校验结果；</li>
					<li>在填写过程中，如果您对填写的格式有所疑问，可以参照题目右侧的填写示例；</li>
				</ol>
		</div>
	</div>
	<div class="page-button" id="first" style="padding:10px;text-align:center;">
		<a href="javascript://" onclick="nextPage(true)" class="btn btn-large btn-success">开始填写调查问卷</a>
	</div>
</div>

<!-- 第一页：种植基本信息 -->
<div class="page" id="1">
<!-- 1.1 省市县 -->
	<?php
		$q_adm_attrs = array(
				'id' => 'administrative'
			);
		$q_adm_fields = array(
				'0' => 'prov', 
				'1' => 'city',
				'2' => 'dist'
			);
		$q_adm_help = '提示：先选择省（直辖市），再依次选择市和区县';

		q_open('adms', $q_adm_attrs, '请选择葡萄园所在的省、市以及区县', $q_adm_fields);
	?>
	<div class="span4">
		<select class="prov autowidth validate[required]" id="prov" name="prov"></select>
		<select class="city autowidth validate[condRequired[prov]]" id="city" name="city" style="display: none;"></select>
		<select class="dist autowidth validate[condRequired[prov,city]]" id="dist" name="dist" style="display: none;">
			<option value="default">请选择</option>
		</select>
	</div>
	<?php
		q_help_open($q_adm_help);
		q_close(); 
	?>

<!-- 1.2 地址 -->
	<?php
		q_open('address', NULL,'请填入葡萄园的详细地址', 'address');
		$q_address_help = '提示：省市区信息无需重复填写';
		$q_address_example = '填写示例：池口镇彭姥岭村（灵峰庄园南）';
	?>
		<div class="span4">
			<?php $input_address = array(
											'name' => 'address',
											'value' => trim(set_value('address')),
											'class' => 'input-large validate[required]', // 前端验证
											'id' => 'address_input',
											'autocomplete' => $autocompleteStatus,
										);
			echo form_input($input_address); ?>
		</div>
	<?php
		q_help_open($q_address_help, $q_address_example);
		q_close();
	?>

<!-- 1.3 栽培类型 -->
	<?php
		q_open('cultivation', NULL, '请选择葡萄园栽培类型', 'type_of_cultivation');
		$q_cultivation_help = '';
		$q_cultivation_example = '';
	?>
	<div class="span4">
	<?php 
		$cultivation_sets = array (
			'open' => '露地栽培',
			'protection' => '设施栽培');
		_radio_open('type_of_cultivation', $cultivation_sets);
	?>
	</div>
	<? q_close(); ?>
<!-- 选择露地栽培则隐藏下一题并清除下一题选项 -->
<script type="text/javascript">
	$(document).ready(function(){
		if($("input[name='type_of_cultivation']:checked").attr('id') != 'type_of_cultivation_protection'){ // 载入页面完成时即判定，防止Next/Back导致的bug
			$("#protection-div").hide();
	        $("input[name=function_of_protection]:checked").prop("checked", false);
	        $("input[name=structure_of_protection]:checked").prop("checked", false);
	    }
	    else {
	        $("#protection-div").show();
	    }

	    $("input[name='type_of_cultivation']").click(function(){
	        var currentID = $(this).attr('id');
	        if(currentID == 'type_of_cultivation_open') {
		        $("#protection-div").hide();
		        $("input[name=function_of_protection]:checked").prop("checked", false);
		        $("input[name=structure_of_protection]:checked").prop("checked", false);
		    }
		    else {
		        $("#protection-div").show();
		    }
	    });
	});
</script>

<!-- 1.4 设施类型 -->
	<?php
		$q_protection_hidden = (isset($_POST['type_of_cultivation']) && $_POST['type_of_cultivation'] == '设施栽培')
								?'display:block;':'display:none;';	// 后端判定，未选定后隐藏
		
		q_open('protection', array('id'=>'protection-div','style'=>$q_protection_hidden),
				'请选择设施栽培类型',	array('function_of_protection','structure_of_protection'));
	?>
	<div class="span2">
		<div class="sub-q">设施功能</div>
		<?php 
			$protection_function_sets = array (
				'promoting' => '促早栽培',
				'delay' => '延迟栽培',
				'rain_escape' => '避雨栽培');
			_radio_open('function_of_protection', $protection_function_sets);
		?>
	</div>
	<div class="span2">
		<div class="sub-q">设施结构</div>
		<?php
			$protection_structure_sets = array (
				'plastic_greenhouse' => '塑料大棚',
				'sunlight_greenhouse' => '日光温室',
				'temp_ctrl_greenhouse' => '加温温室',
				'simple_canopy' => '简易避雨棚');
			_radio_open('structure_of_protection', $protection_structure_sets);
		?>
	</div>
	<? q_close(); ?>

<!-- 1.5 是否观光 -->
	<?php
		q_open('sightseeing', NULL, '葡萄园是否有观光、采摘业务', 'is_sightseeing');
		$yes_no_sets = array (
			'yes' => '是',
			'no' => '否');
	?>
		<div class="span2">
			<?	_radio_open('is_sightseeing', $yes_no_sets); ?>
		</div>
	<?php
		q_close();
	?>

<!-- 1.6 总面积 -->
	<? q_open('area', NULL, '葡萄园种植总面积', 'total_area'); ?>
		<div class="span4 input-append">
			<? $input_total_area = array(
											'name' => 'total_area',
											'value' => trim(set_value('total_area')),
											'class' => 'input-mini validate[required, custom[number], min[0]]',
											'id' => 'total_area_input',
											'autocomplete' => $autocompleteStatus,
										);
			form_input_appanded_open($input_total_area, '亩'); ?>
		</div>
	<? q_close(); ?>

<!-- 1.7 种植的主要品种和面积 -->
	<div class="q-div" name="var">
		<div class="q-title">种植的葡萄品种、面积及用途</div>
		<div class="row">
		<div class="span5">
		<table class="table table-nonfluid" style="font-size:12px;margin-bottom:0px">
			<thead>
				<tr>
					<th>#</th>
					<th>品种名称</th>
					<th>种植面积</th>
					<th>葡萄用途</th>
				</tr>
			</thead>
			<tbody id="varieties">
				<tr id="primary-variety">
					<td>1</td>
					<td><input type="text" name="variety_name[]" value="<? echo set_value('variety_name[]'); ?>" class="input-small validate[required]" id="variety-name-1" autocomplete="off"></td>
					<td><div class="input-append"><input type="text" name="variety_area[]"  value="<? echo set_value('variety_area[]'); ?>" class="input-mini validate[required,custom[number],min[0]]" id="variety-area-1"autocomplete="off"><span class="add-on">亩</span></div></td>
					<td><select name="variety_usage_select[]" class="validate[required] variety-usage input-small" id="variety-usage-select-1">
							<option value="" <?php echo set_select('variety_usage_select[]', '', TRUE); ?>>请选择</option>
							<option value="鲜食" <?php echo set_select('variety_usage_select[]', '鲜食'); ?>>鲜食</option>
							<option value="酿酒" <?php echo set_select('variety_usage_select[]', '酿酒'); ?>>酿酒</option>
							<option value="制干" <?php echo set_select('variety_usage_select[]', '制干'); ?>>制干</option>
							<option value="制汁" <?php echo set_select('variety_usage_select[]', '制汁'); ?>>制汁</option>
							<option value="other" <?php echo set_select('variety_usage_select[]', 'other'); ?>>其它用途</option>
						</select><input type="text" name="variety_usage[]"  value="<? echo set_value('variety_usage[]'); ?>" class="input-small validate[required, custom[chinese]" style="display:none" id="variety-usage-1" autocomplete="off" placeholder="请填写用途">
					</td>
				</tr>
			</tbody>
		</table>
		<a href="javascript://" onclick="addVariety()" class="btn" style="font-size:12px;margin-top:8px;">增加一个品种</a>
		<a href="javascript://" onclick="removeVariety()" class="btn" style="font-size:12px;margin-top:8px">减少一个品种</a>
		</div>
		<div class="span3 q-help">
			提示：请将实际销售的葡萄品种<strong>添加完全</strong><br>需要添加品种请点按 "<span class="text-info">增加一个品种</span>"<br><span class="q-example text-info">填写示例：巨峰&nbsp;&nbsp;&nbsp;20&nbsp;&nbsp;&nbsp;&nbsp;鲜食<br>红地球&nbsp;&nbsp;&nbsp;10&nbsp;&nbsp;&nbsp;&nbsp;鲜食<br>赤霞珠&nbsp;&nbsp;&nbsp;10&nbsp;&nbsp;&nbsp;&nbsp;酿酒</span>
		</div>
		</div>
	<!-- 其它品种实现 -->
		<script type="text/javascript">
			$(document).ready(function(){
				$('#variety-usage-select-1').change(otherInput);
			});
		</script>
	<!-- 与收益表格联动的JS实现 -->
		<script type="text/javascript">
			$(document).ready(function(){
				$('#variety-name-1').keyup(function(e){
					$('#output-variety-1').val($(this).val());
				});
			});
		</script>
	<!-- 动态多品种添加/删除/验证 -->
	<script src="/js/myjs/jquery.varietiesAddRemoveValidate.js"></script>
	</div>

<!-- 第1页帮助提示 -->
	<div class="q-div" id="tips-1">
		<div class="alert alert-error" id="area-validation-err" style="display:none">
			<strong>错误提示</strong>：您输入的葡萄园总面积与各品种面积之和相差较多，请检查后继续</div>
		<p class="q-help">提示：填写完成并且确认无误后，单击下一页按钮继续</p>
	</div>

<!-- 第1页按钮 -->
	<div class="page-button" id="first" style="padding:10px;text-align:center;">
		<a href="javascript://" onclick="nextPage(validatePage())" class="btn btn-primary">下一页</a>
	</div>

</div>

<!-- 第二页：种植者信息-->
<div class="page" id="2" style="display:none;">
<!-- 20%进度条 -->
	<div class="text-center">
	    <span class="q-help" style="font-size:12px">您已完成调查问卷的20%</span>
	    <div class="progress progress-striped">
		    <div class="bar" style="width: 20%;"></div>
	    </div>
	</div>

<!-- 2.1 种植者类型-->
	<?php
		q_open('growers_type', NULL, '种植者类型', 'type_of_growers');
		$type_of_growers_sets = array(
			'enterprise' => '企业种植基地',
			'cooperative_member' => '合作社成员',
			'cooperative_leader' => '合作社领导',
			'other' => '其他农户'
		);
	?>
		<div class="span4">
			<? _radio_open('type_of_growers', $type_of_growers_sets); ?>
		</div>
	<?php
		q_close();
	?>

<!-- 2.2 主要经济来源 -->
	<?php
		q_open('primary_income', NULL, '葡萄生产是否为您的主要经济来源', 'is_primary_income');
	?>
		<div class="span2">
			<? _radio_open('is_primary_income', $yes_no_sets); ?>
		</div>
	<? q_close(); ?>

<!-- 2.3 是否加入合作社 -->
	<?php
		q_open('in_cooperative', NULL, '您是否加入合作社', 'is_in_cooperative');
	?>
		<div class="span2">
			<? _radio_open('is_in_cooperative', $yes_no_sets); ?>
		</div>
	<? q_close(); ?>

<!-- 2.4 从事葡萄生产的人员平均年龄*? -->
	<?php
		q_open('avg_age', NULL, '请选择从事葡萄生产的人员平均年龄', 'average_age');

		$average_age_sets = array('1' => '20~30岁', '31~40岁', '41~50岁', '51~60岁', '60岁以上');
	?>
		<div class="span4">
			<? _select_open('average_age', $average_age_sets, TRUE); ?>
		</div>
	<? q_close(); ?>

<!-- 2.5 种植者的最高学历-->
	<? q_open('edu', NULL, '请选择种植者的最高学历', 'education');
		$education_sets = array('1' => '小学以下', '小学', '中学', '大专', '本科及以上') ?>
		<div class="span4">
			<? _select_open('education', $education_sets, TRUE); ?>
		</div>
	<? q_close(); ?>

<!-- 2.6 种植葡萄的时间 -->
	<? q_open('creer', NULL, '请选择您种植葡萄的时间', 'creer_length');
		$creer_length_sets = array('1' => '2年以内', '2~5年', '5~10年', '10年以上');
	?>
		<div class="span4">
			<? _select_open('creer_length', $creer_length_sets, TRUE); ?>
		</div>
	<? q_close(); ?>

<!-- 2.7 接受培训 -->
	<? q_open('trainning', NULL, '您是否接受过葡萄生产方面的技术培训', 'is_trained'); ?>
		<div class="span4">
			<? _radio_open('is_trained', $yes_no_sets); ?>
		</div>
	<? q_close(); ?>

<!-- 第2页帮助提示 -->
	<div class="q-div" id="tips-">
		<div class="q-help">提示：需要修改之前的问卷，单击上一页<br>填写完成后，单击下一页按钮</div>
	</div>
</div>

<!-- 第三页 土地与建园情况-->
<div class="page" id="3" style="display:none;">
<!-- 40%进度条 -->
	<div class="text-center">
	    <span class="q-help" style="font-size:12px">您已完成调查问卷的40%</span>
	    <div class="progress progress-striped">
		    <div class="bar" style="width: 40%;"></div>
	    </div>
	</div>

<!-- 3.1 建园年份 -->
	<? q_open('建园年份', NULL, '请填入葡萄园建立年份', 'built_in'); ?>
		<div class="span4">
			<? $input_built_in = array(
									'name' => 'built_in',
									'value' => trim(set_value('built_in')),
									'class' => 'input-small validate[required, custom[year], custom[yearPast]]',
									'id' => 'built_in_input',
									'autocomplete' => 'off');
				echo form_input($input_built_in); ?>
		</div>
	<? q_help_open('提示：只需输入年份的数值即可','填写示例：2012');
		q_close(); ?>

<!-- 3.2 使用年限 -->
	<? q_open('使用年限', NULL, '请填入预计葡萄园可使用年限', 'vineyard_lifetime'); ?>
		<div class="span4 input-append">
			<? $input_vineyard_lifetime = array(
									'name' => 'vineyard_lifetime',
									'value' => trim(set_value('vineyard_lifetime')),
									'class' => 'input-mini validate[required, min[1], custom[integer]',
									'id' => 'vineyard_lifetime_input',
									'autocomplete' => $autocompleteStatus);
				form_input_appanded_open($input_vineyard_lifetime, '年'); ?>
		</div>
	<? q_help_open('提示：只需输入年限的数值即可','填写示例：20');
		q_close(); ?>

<!-- 3.3 是否自家土地 -->
	<? q_open('是否自家', NULL, '您的葡萄园用地是否为自家土地', 'is_land_owner'); ?>
		<div class="span4">
			<? _radio_open('is_land_owner', $yes_no_sets); ?>
		</div>
		<? q_help_open('提示：如果土地不需要租金，请选择 "<span class="text-info">是</span>"；<br>如果土地需要租金投入，请选择 "<span class="text-info">否</span>"'); ?>
	<? q_close(); ?>

<!-- 3.4 显性土地成本 -->
	<? q_open('土地租金', array('id'=>'land-rent-div'), '请填入您葡萄园租用土地<b>每年、每亩</b>的租金', 'cost_land_rent'); ?>
		<div class="span4 input-append input-prepend">
			<? $input_cost_land_rent = array(
						'name' => 'cost_land_rent',
						'value' => trim(set_value('cost_land_rent')),
						'class' => 'input-mini validate[required, custom[number], min[0]]',
						'id' => 'cost_land_rent_input',
						'autocomplete' => $autocompleteStatus,
						); ?>
			<span class="add-on">每年每亩</span><? echo form_input($input_cost_land_rent); ?><span class="add-on">元</span>
		</div>
	<? q_help_open('提示：只需输入金额的数值即可','填写示例：500');
		q_close(); ?>

<!-- 3.4 隐性土地成本 -->
	<? q_open('当地租金', array('id'=>'local-rent-div'), '当地农用土地<b>每年、每亩</b>的流转费用一般为', 'local_land_price'); ?>
		<div class="span4 input-append input-prepend">
			<? $input_local_land_price = array(
						'name' => 'local_land_price',
						'value' => trim(set_value('local_land_price')),
						'class' => 'input-mini validate[required, custom[number], min[0]]',
						'id' => 'local_land_price_input',
						'autocomplete' => $autocompleteStatus,
						);
			?>
			<span class="add-on">每年每亩</span><? echo form_input($input_local_land_price); ?><span class="add-on">元</span>
		</div>
	<? q_help_open('提示：只需输入金额的数值即可','填写示例：500');
		q_close(); ?>

<!-- 显现隐性土地成本JS实现 -->
<script type="text/javascript">
	$(document).ready(function(){
		if($("input[name='is_land_owner']:checked").attr('id') != 'is_land_owner_yes'){ // 载入页面完成时即判定，防止Next/Back导致的bug
			$("#local-rent-div").hide();
	    }
	    else {
	        $("#local-rent-div").show();
	    }
	    if($("input[name='is_land_owner']:checked").attr('id') != 'is_land_owner_no'){ // 载入页面完成时即判定，防止Next/Back导致的bug
			$("#land-rent-div").hide();
	    }
	    else {
	        $("#land-rent-div").show();
	    }
	    $("input[name='is_land_owner']").click(function(){
	        var currentID = $(this).attr('id');
	        if(currentID == 'is_land_owner_yes') {
		        $("#local-rent-div").show();
		        $("#land-rent-div").hide();
		    }
		    if(currentID == 'is_land_owner_no') {
		        $("#local-rent-div").hide();
		        $("#land-rent-div").show();
		    }
	    });
	});
</script>

<!-- 3.5 建园物质 -->
	<? q_open('建园物质', NULL, '建园投入的<b>物质成本</b>','cost_built_materials'); ?>
		<div class="span3 input-append">
			<? $input_cost_built_materials = array(
				'name' => 'cost_built_materials',
				'value' => trim(set_value('cost_built_materials')),
				'class' => 'input-mini validate[required, min[0],custom[number], min[0]]',
				'id' => 'cost_built_materials_input',
				'autocomplete' => $autocompleteStatus,
				);
			form_input_appanded_open($input_cost_built_materials, '元');
			?>
		</div>
	<? q_help_open('提示：指建设葡萄园时投入的<b style="color:#555">全部物质费用</b><br>包括购买苗木、水泥、钢架、铁丝、农膜、基础灌溉设施等<br>只需输入金额的数值即可','', TRUE);
		q_close();
	?>

<!-- 3.6 建园人工 -->
	<? q_open('建园人工', NULL, '建园投入的<b>人工成本</b>','cost_built_labor'); ?>
		<div class="span3 input-append">
			<? $input_cost_built_labor = array(
				'name' => 'cost_built_labor',
				'value' => trim(set_value('cost_built_labor')),
				'class' => 'input-mini validate[required, custom[number], min[0]]',
				'id' => 'cost_built_labor_input',
				'autocomplete' => $autocompleteStatus,
				);
			form_input_appanded_open($input_cost_built_labor, '元');
			?>
		</div>
	<? q_help_open('提示：指建设葡萄园时支付的<b style="color:#555">全部人力报酬</b><br>包括平整土地、搭建葡萄架、挖排水沟、定植苗木等所有的人工开支<br>只需输入金额的数值即可','', TRUE);
		q_close();
	?>

<!-- 3.7 维护费用 -->
	<? q_open('维护费', NULL, '请填入葡萄园<b>每年</b>新增维护费用', 'cost_renovation'); ?>
		<div class="span3">
			<div class=" input-append input-prepend" id="cost_renovation_div">
			<? $input_cost_renovation = array(
				'name' => 'cost_renovation',
				'value' => trim(set_value('cost_renovation')),
				'class' => 'input-mini validate[required, custom[number], min[0]]',
				'id' => 'cost_renovation_input',
				'autocomplete' => $autocompleteStatus,
				);
			?>
			<span class="add-on">每年</span><? echo form_input($input_cost_renovation); ?><span class="add-on">元</span>
			</div>
		<label for="no_input_cost_renovation" class="checkbox"><input type="checkbox" name="no_cost_renovation" value="1" id="no_input_cost_renovation"> 每年均没有维护费投入</label>
		</div>
	<? q_help_open('提示：指<strong>每年平均</strong>需要的葡萄园维护费用<br>包括园地修缮、苗木更新等投入的<strong>物质成本与人工成本</strong>的总和', '', TRUE);
		q_close(); ?>

<!-- 第3页帮助提示-->
	<div class="q-div" id="tips-">
		<div class="q-help">提示：需要修改之前的问卷，单击上一页<br>填写完成后，单击下一页按钮</div>
	</div>
</div>

<!-- 第四页 生产季物质与人工-->
<div class="page" id="4" style="display:none;">
<!-- 60%进度条 -->
	<div class="text-center">
	    <span class="q-help" style="font-size:12px">您已完成调查问卷的60%</span>
	    <div class="progress progress-striped">
		    <div class="bar" style="width: 60%;"></div>
	    </div>
	</div>

<!-- 4.1 化肥投入 -->
	<? add_material_question('化肥', 'cost_chemical_fertilizer'); ?>

<!-- 4.2 有机肥投入 -->
	<? add_material_question('有机肥', 'cost_organic_fertilizer'); ?>

<!-- 4.3 农药 -->
	<? add_material_question('农药', 'cost_pesticide'); ?>

<!-- 4.4 生长调节剂 -->
	<? add_material_question('生长调节剂', 'cost_regulator'); ?>

<!-- 4.5 套袋 -->
	<? add_material_question('套袋', 'cost_plastic'); ?>

<!-- 4.6 农膜 -->
	<? add_material_question('农膜', 'cost_film'); ?>

<!-- 4.7 水 -->
	<? add_material_question('水费', 'cost_water', TRUE, TRUE); ?>

<!-- 4.8 电 -->
	<? add_material_question('电费', 'cost_electric', TRUE, TRUE); ?>

<!-- 4.9 其它物质 -->
	<div class="q-div">
		<div class="q-title">请填写 <b>其它物质</b> 的资金投入</div>
		<div class="row">
		<div class="span4">
		<table class="table table-nonfluid" style="font-size:12px;margin-bottom:0px" id="other-materials-table">
			<thead>
				<tr>
					<th>#</th>
					<th>其他项目名称</th>
					<th>投入金额</th>
				</tr>
			</thead>
		<tbody id="other-materials">
			<tr id="primary-other-material">
				<td>1</td>
				<td><?php echo form_input('other_material_description[]', trim(set_value('other_material_description[]')), 'id="other-material-description-1" class="input-small validate[required]" autocomplete="off"'); ?></td>
				<td><div class="input-append"><?php $other_material_cost_set = array(
																	'name' => 'other_material_cost[]',
																	'id' => 'other-material-cost-1',
																	'class' => 'input-mini validate[required, custom[number], min[0]]',
																	'autocomplete' => 'off',
																	// 'placeholder' => '点击输入投入金额'
																	); 
										form_input_appanded_open($other_material_cost_set, '元'); ?></div>
				</td>
			</tr>
		<? _table_close(); ?>
		<a href="javascript://" onclick="addOtherMaterial()" class="btn" id="other-m-btn-add" style="font-size:12px;margin-top:8px;margin-bottom:10px">增加一栏</a>
		<a href="javascript://" onclick="removeOtherMaterial()" class="btn" id="other-m-btn-rm" style="font-size:12px;margin-top:8px;margin-bottom:10px">减少一栏</a>
		<label for="no-cost-other-material" class="checkbox" style="margin-bottom:10px"><input type="checkbox" name="no_cost_other_material" value="1" id="no-cost-other-material"> 没有其它项目的投入</label>
	<!-- 动态添加其它成本的JS实现 -->
		<script src="/js/myjs/jquery.materialsAddRemoveValidate.js"></script>
	<!-- 无其它成本的JS实现 -->
		<script type="text/javascript">
			$(document).ready(function(){
				$('input[id="no-cost-other-material"]').click(function(){
					// alert($(this).prop('checked'));
					if($(this).prop('checked') == true){
						$('#other-materials-table').hide();
						$('#other-m-btn-add').hide();
						$('#other-m-btn-rm').hide();
						$('input[name^="other_material"]').val('');
					}
					else{
						$('#other-m-btn-add').show();
						$('#other-m-btn-rm').show();
						$('#other-materials-table').show();
					}
				});
			});
		</script>
		</div>
		<? q_help_open('提示：请将<strong>项目名称</strong>与<strong>投入金额</strong>分开填写<br>需要添加一项其它项目时请点按 "<span class="text-info">添加一栏</span>" 按钮，<br>如果不需要最后一栏的内容，点按 "<span class="text-info">减少一栏</span>" 按钮', '填写示例：第一格中填写"防鸟网"，第二格中填写"200"'); ?>
		</div>
	</div>

<!-- 第4页帮助提示 -->
	<div class="q-div" id="tips-">
		<div class="q-help">提示：需要修改之前的问卷，单击上一页<br>填写完成后，单击下一页按钮</div>
	</div>
</div>

<!-- 第五页：机械与人工成本 -->
<div class="page" id="5" style="display:none;">
<!-- 80%进度条 -->
	<div class="text-center">
	    <span class="q-help" style="font-size:12px">您已完成调查问卷的80%</span>
	    <div class="progress progress-striped">
		    <div class="bar" style="width: 80%;"></div>
	    </div>
	</div>

<!-- 5.1~5.5 机械购置情况 -->
<div class="q-div">
	<div class="q-title">请填写购置农业机械情况</div>
	<table class="table table-nonfluid" style="font-size:12px;margin-bottom:0px" id="machinery-table">
		<thead>
			<tr>
				<th>#</th>
				<th>机械名称</th>
				<th>单价</th>
				<th>购置数量</th>
				<th>机械寿命</th>
				<th>燃油种类</th>
			</tr>
		</thead>
		<tbody id="machinery">
			<tr id="primary-machine">
				<td>1</td>
				<td><input type="text" name="machine_name[]" id="machine-name-1" class="input-small validate[required]" autocomplete="off"></td>
				<td>
					<div class="input-append"><input type="text" name="machine_cost_per_unit[]" id="machine-cost-per-unit-1" class="input-mini validate[required, custom[number], min[0]]" autocomplete="off"><span class="add-on">元</span></div>
				</td>
				<td>
					<div class="input-append"><input type="text" name="machine_number_of_unit[]" id="machine-number-of-unit-1" class="input-xmini validate[required, custom[integer], min[0]]" autocomplete="off"><span class="add-on">台</span></div>
				</td>
				<td>
					<div class="input-append"><input type="text" name="machine_lifetime[]" id="machine-lifetime-1" class="input-xmini validate[required, custom[integer], min[0]]" autocomplete="off"><span class="add-on">年</span></div>
				</td>
				<td><select class="autowidth" name="machine_fuel_type[]" id="machine-fuel-type-1">
						<option value=''>请选择</option>
						<option value="柴油">柴油</option>
						<option value="汽油">汽油</option>
					</select>
				</td>
			</tr>
	<? _table_close(); ?>
	<div class="row">
		<div class="span3">
		<a href="javascript://" onclick="addMachinery()" class="btn" id="machinery-btn-add" style="font-size:12px;margin-top:8px;margin-bottom:10px">增加一栏</a>
		<a href="javascript://" onclick="removeMachinery()" class="btn" id="machinery-btn-rm" style="font-size:12px;margin-top:8px;margin-bottom:10px">减少一栏</a>
		<label for="no-machinery" class="checkbox" style="margin-bottom:10px"><input type="checkbox" name="no_machinery" value="1" id="no-machinery"> 没有农业机械的成本投入</label>
	<!-- 动态机械成本的JS实现 -->
		<script src="/js/myjs/jquery.machineryAddRemoveValidate.js"></script>
	<!-- 无机械成本的JS实现 -->
		<script type="text/javascript">
			$(document).ready(function(){
				$('input[id="no-machinery"]').click(function(){
					// alert($(this).prop('checked'));
					if($(this).prop('checked') == true){
						$('#machinery-table').hide(); // "机械成本"表格
						$('#machinery-btn-add').hide(); // "添加一行"按钮
						$('#machinery-btn-rm').hide(); // "删除一行"按钮
						$('input[name^="machine"]').val(''); // 清空"机械成本"所有text
						$('select[name^="machine"]').val(''); // 清空"机械成本"所有select
						$('#local-diesel-price-div').hide(); // "柴油价格"问题
						$('#local-gasoline-price-div').hide(); // "汽油价格"问题
					}
					else{
						$('#machinery-table').show();
						$('#machinery-btn-add').show();
						$('#machinery-btn-rm').show();
					}
				});
			});
		</script>
		</div>
		<div style="padding-top:8px">
			<? q_help_open('提示：请对应表格标题填写各栏<br>如果您未购置任何农业机械, 请选中 "没有农业机械的成本投入"','填写示例：打药机 &nbsp;&nbsp; 1800 &nbsp;&nbsp; 1 &nbsp;&nbsp; 20 &nbsp;&nbsp; 汽油', TRUE); ?>
		</div>
	</div>
</div>

<!-- 5.6 燃油费用 -->
<div class="q-div" name="燃油费">
	<div class="q-title">请填入今年<b>燃油费</b>的资金投入</div>
	<div class="row">
		<div class="span4">
			<div class="input-append" id="cost-fuel-div">
				<input type="text" name="cost_fuel" value="" class="input-mini validate[required, min[0], custom[number]]" id="cost-fuel-input" autocomplete="off"><span class="add-on">元</span>
			</div>
			<label for="no-cost-fuel" class="checkbox">
				<input type="checkbox" name="no_cost_fuel" value="1" id="no-cost-fuel"> 没有燃油费投入
			</label>
		</div>
		<div class="span4 q-help" style="margin-bottom:5px;">提示：只需输入金额的数值即可<br>如果您没有投入燃油费，请选中 "没有燃油费投入"<br><span class="q-example text-info">填写示例：500</span></div>
	</div>
</div>
<!-- 无燃油费和当地油价的JS实现 -->
	<script type="text/javascript">
		$(document).ready(function(){
			$('input[id="no-cost-fuel"]').click(function(){
				// alert($(this).prop('checked'));
				if($(this).prop('checked') == true){
					$('#cost-fuel-div').hide();
					$('#local-diesel-price-div').hide();
					$('#local-gasoline-price-div').hide();
					$('#cost-fuel-input').val('');
				}
				else{
					$('#cost-fuel-div').show();
					$('#local-diesel-price-div').show();
					if(thereIsGasoline())
						$('#local-gasoline-price-div').show();
					if(noDiesel() == 0)
						$('#local-diesel-price-div').show();
				}
			});
		});
	</script>
<!-- 动态显示柴油价的JS实现 -->
		<script type="text/javascript">
			$(document).ready(function(){
				$('#machine-fuel-type-1').change(noDiesel);
			});
		</script>
<!-- 5.7 当地柴油价 -->
	<? q_open('当地柴油价', array('id'=>'local-diesel-price-div','style'=>'display:none;'), '请填入当地<b>每升柴油</b>的价格', 'local_diesel_price'); ?>
		<div class="span4 input-append input-prepend">
			<? $input_local_diesel_price = array(
						'name' => 'local_diesel_price',
						'value' => trim(set_value('local_diesel_price')),
						'class' => 'input-mini validate[custom[number], min[0]]',
						'id' => 'local-diesel-price-input',
						'autocomplete' => "off",
						); ?>
			<span class="add-on">每升</span><? echo form_input($input_local_diesel_price); ?><span class="add-on">元</span>
		</div>
	<? q_help_open('提示：只需输入金额的数值即可','填写示例：500');
		q_close(); ?>

<!-- 动态显示汽油价的JS实现 -->
	<script type="text/javascript">
		$(document).ready(function(){
			$('#machine-fuel-type-1').change(thereIsGasoline);
		});
	</script>
<!-- 5.7 当地汽油价 -->
	<? q_open('当地汽油价', array('id'=>'local-gasoline-price-div', 'style'=>'display:none;'), '请填入当地<b>每升汽油</b>的价格', 'local_gasoline_price'); ?>
		<div class="span4 input-append input-prepend">
			<? $input_local_gasoline_price = array(
						'name' => 'local_gasoline_price',
						'value' => trim(set_value('local_gasoline_price')),
						'class' => 'input-mini validate[custom[number], min[0]]',
						'id' => 'local-gasoline-price-input',
						'autocomplete' => "off",
						); ?>
			<span class="add-on">每升</span><? echo form_input($input_local_gasoline_price); ?><span class="add-on">元</span>
		</div>
	<? q_help_open('提示：只需输入金额的数值即可','填写示例：500');
		q_close(); ?>

<!-- 5.8 机械租赁费 -->
	<? q_open('机械租赁费', NULL, '请填入今年<strong>租用农机具</strong>作业所花费资金','cost_machine_rent'); ?>
	<div class="span4">
		<div class="input-append" id="cost-machine-rent_div">
			<? $input_cost_machine_rent = array(
							'name' => 'cost_machine_rent',
							'id' => 'cost-machine-rent-input',
							'value' => trim(set_value('cost_machine_rent')),
							'class' => 'input-mini validate[required, custom[number], min[0]',
							'autocomplete' => 'off'
							);
			echo form_input($input_cost_machine_rent); ?><span class="add-on">元</span>
		</div>
		<label for="no_input_cost-machine-rent" class="checkbox">
				<input type="checkbox" name="no_cost_machine_rent" value="1" id="no_input_cost-machine-rent"> 没有机械租赁投入
			</label>
	</div>
	<div class="span4 q-help" style="margin-bottom:5px;">提示：只需输入金额的数值即可<br>如果您没有租赁过农机具，请选中 "没有机械租赁投入"<br><span class="q-example text-info">填写示例：300</span></div>
	<? q_close(); ?>

<!-- 5.9 雇佣人工费用 -->
	<? q_open('雇佣人工费用', NULL, '请填入今年<strong>雇佣人工</strong>所花费的资金', 'cost_paid_labor'); ?>
		<div class="span4">
			<div class="input-append">
				<? $input_cost_paid_labor = array(
							'name' => 'cost_paid_labor',
							'id' => 'cost-paid-labor-input',
							'value' => trim(set_value('cost_paid_labor')),
							'class' => 'input-mini validate[required, custom[number], min[0]',
							'autocomplete' => 'off'
							);
				echo form_input($input_cost_paid_labor); ?><span class="add-on">元</span>
			</div>
		</div>
		<? q_help_open('提示：填入支付给雇佣人员的全部工资总和','填写示例：2500');
	q_close(); ?>

<!-- 5.10 雇佣用工量 -->
	<? q_open('雇佣用工量', NULL, '请填入今年<strong>总共</strong>雇佣人员的数量', 'paid_labor_num'); ?>
		<div class="span4 input-append">
			<? $input_paid_labor_num = array(
							'name' => 'paid_labor_num',
							'value' => trim(set_value('paid_labor_num')),
							'id' => 'paid-labor-num-input',
							'class' => 'input-mini validate[required, custom[integer], min[1]]',
							'autocomplete' => 'off');
			echo form_input($input_paid_labor_num); ?><span class="add-on">人</span>
		</div>
	<? q_help_open('提示：指领取工资报酬的人员数，例如当年共计雇佣20人，平均每个人工作5天，则填入<span class="text-info">20</span>');
	q_close(); ?>

<!-- 5.11 自家用工量 -->
	<? q_open('自家用工量', NULL, '请填入<strong>自家</strong>投入人工的数量', 'unpaid_labor_num'); ?>
		<div class="span4">
			<div class="input-append" id="unpaid-labor-num_div">
				<? $input_unpaid_labor_num = array(
								'name' => 'unpaid_labor_num',
								'value' => trim(set_value('unpaid_labor_num')),
								'id' => 'unpaid-labor-num-input',
								'class' => 'input-mini validate[required, custom[integer], min[1]]',
								'autocomplete' => 'off');
				echo form_input($input_unpaid_labor_num); ?><span class="add-on">人</span>
			</div>
			<label for="no_input_unpaid-labor-num" class="checkbox">
				<input type="checkbox" name="no_unpaid_labor_num" value="1" id="no_input_unpaid-labor-num"> 没有自家劳动力投入
			</label>
		</div>
		<div class="span4 q-help" style="margin-bottom:5px;">提示：指<strong>不领取</strong>工资报酬的人工数<br>如果没有未支付报酬人工，请选中"没有自家劳动力投入"<br><span class="q-example text-info">填写示例：2</span></div>
	<? q_close(); ?>

<!-- 5.12 当地用工单价 -->
	<? q_open('当地用工单价', NULL, '请填入当地平均用工<strong>单价</strong>', 'local_labor_price'); ?>
		<div class="span4 input-append input-prepend">
			<span class="add-on">每人每天</span>
			<? $input_local_labor_price = array(
							'name' => 'local_labor_price',
							'value' => trim(set_value('local_labor_price')),
							'id' => 'local-labor-price-input',
							'class' => 'input-mini validate[required, custom[number], min[0]]',
							'autocomplete' => 'off');
			echo form_input($input_local_labor_price); ?><span class="add-on">元</span>
		</div>
	<? q_help_open('提示：只需填入单价的金额即可','填写示例：80');
	q_close(); ?>

<!-- 第五页提示信息 -->
	<div class="q-div" id="tips-">
		<div class="q-help">提示：需要修改之前的问卷，单击上一页<br>填写完成后，单击下一页按钮</div>
	</div>
</div>

<!-- 第六页：收益情况 -->
<div class="page" id="6" style="display:none;">
<!-- 100%进度条 -->
	<div class="text-center">
	    <span class="q-help" style="font-size:12px">您即将完成此次调研</span>
	    <div class="progress progress-striped">
		    <div class="bar" style="width: 100%;"></div>
	    </div>
	</div>

<!-- 6.1 收益情况 -->
	<div class="q-div">
		<div class="q-title">请填写葡萄园的收益情况</div>
		<table class="table table-nonfluid" style="font-size:12px;margin-bottom:0px" id="machinery-table">
		<thead>
			<tr>
				<th>#</th>
				<th>葡萄品种</th>
				<th>产量</th>
				<th>单价</th>
			</tr>
		</thead>
		<tbody id="output">
			<tr id="primary-output">
				<td>1</td>
				<td>
					<input type="text" class="input-small uneditable-input" name="output_variety[]" id="output-variety-1" disabled>
				</td>
				<td>
					<div class="input-append">
						<input type="text" name="output_production[]" id="output-production-1" class="input-mini validate[required,custom[integer],min[0]" autocomplete="off"><span class="add-on">斤</span>
					</div>
				</td>
				<td>
					<div class="input-append input-prepend">
						<span class="add-on">每斤</span><input type="text" name="output_unit_price[]" id="output-unit-price-1" class="input-xmini validate[required,custom[number],min[0]" autocomplete="off"><span class="add-on">元</span>
					</div>
				</td>
			</tr>
		</tbody>
		</table>
	</div>

<!-- 6.2 总成本 -->
	<? q_open('总投入', NULL, '请填写今年葡萄园的<strong>总投入</strong>', 'cost_subtotal'); ?>
		<div class="span4 input-append">
			<? $input_cost_subtotal = array(
							'name' => 'cost_subtotal',
							'value' => trim(set_value('cost_subtotal')),
							'id' => 'cost-subtotal',
							'class' => 'input-small validate[required, custom[number], min[0]]',
							'autocomplete' => 'off'
							);
					echo form_input($input_cost_subtotal); ?><span class="add-on">元</span>
		</div>
	<? q_help_open('', '');
	q_close(); ?>

<!-- 6.3 总收益 -->
	<? q_open('总收益', NULL, '请填写今年葡萄园的<strong>总销售额</strong>', 'benefit_subtotal'); ?>
		<div class="span4 input-append">
			<? $input_benefit_subtotal = array(
							'name' => 'benefit_subtotal',
							'value' => trim(set_value('benefit_subtotal')),
							'id' => 'benefit-subtotal',
							'class' => 'input-small validate[required, custom[number], min[0]]',
							'autocomplete' => 'off'
							);
					echo form_input($input_benefit_subtotal); ?><span class="add-on">元</span>
		</div>
	<? q_help_open('', '');
	q_close(); ?>

<!-- 第六页提示信息 -->
	<div class="q-div" id="tips-">
		<div class="q-help">提示：需要修改之前的问卷，单击上一页<br>填写完成后，单击下一页按钮</div>
	</div>
</div>


<!-- 末页 验证信息 -->
<div class="page" id="7" style="display:none;">
	<div class="q-div" id="tips-">
		<div class="q-help" id="allValid" style="display:none">提示：单击下方按钮完成此次调研</div>
		<div class="q-help" id="remainInvalid">提示：单击下方按钮修改错误数据</div>
	</div>
<!-- Submit Button -->
	<div class="page-button" id="last" style="padding:10px;text-align:center;display:none;">
		<input type="submit" class="btn btn-success" value="完成调查问卷" style="">
	</div>
</div>

<!-- Middle Page Buttons -->
		<div class="page-button" id="middle" style="padding:10px;text-align:center;display:none;">
			<a href="javascript://" onclick="prePage()" class="btn btn-primary">上一页</a>
			<a href="javascript://" onclick="nextPage(validatePage())" class="btn btn-primary">下一页</a>
		</div>

	</form>
<!-- 分页实现JS -->
<script type="text/javascript">
	var min_page_id = 1; // 首页页码 Debug用
	var current_page_id = min_page_id;	// 当前页码
	var max_page_id = $(".page").length - 1;	// 总页码数(除去首页)

	$(document).ready(function(){ // Debug用
		if (current_page_id < min_page_id + 1) {
			current_page_id = min_page_id;
		};

		if (current_page_id >= max_page_id) {
			current_page_id = max_page_id;
		};

		$(".page[id!="+current_page_id+"]").hide();
		$(".page[id="+current_page_id+"]").show();
		//	$(".page[id="+current_page_id+"]").show(); // Debug用

		if(current_page_id == max_page_id){
			$(".page-button[id='last']").show();
			$(".page-button[id!='last']").hide();
		};

		if(current_page_id > 1 && current_page_id < max_page_id){
			$(".page-button[id='middle']").show();
			$(".page-button[id!='middle']").hide();
		};
		//alert('current_page_id = ' + current_page_id + "\n"+'max_page_id = ' + max_page_id); // Debug用
	})

	/***
	 *	下一页按钮
	 */
	function nextPage(validity) {
		if(validity){
			current_page_id++;	// 指针加1

			// $('body,html').animate({scrollTop:80},0); // 返回顶部

			if (current_page_id >= max_page_id) { // 设置页码上限
				current_page_id = max_page_id;
				$(".page-button[id='last']").show();
				$(".page-button[id!='last']").hide();				
			};

			// 控制页面显示
			$(".page[id!="+current_page_id+"]").hide();	
			$(".page[id="+current_page_id+"]").show();

			// 控制上下页按钮显示
			if(current_page_id > 1 && current_page_id < max_page_id){ //中间页面
				$(".page-button[id='middle']").show();
				$(".page-button[id!='middle']").hide();
			};
		}
	}

	/***
	 *	上一页按钮
	 */
	function prePage() {
		current_page_id--;
		if (current_page_id <= 1) {
			current_page_id = 1;
			$(".page-button[id='first']").show();
			$(".page-button[id!='first']").hide();
		};

		$(".page[id!="+current_page_id+"]").hide();
		$(".page[id="+current_page_id+"]").show();

		// $('body,html').animate({scrollTop:80},0); // 返回顶部

		// 控制上下页按钮显示
		if(current_page_id > 1 && current_page_id < max_page_id){ //中间页面
			$(".page-button[id='middle']").show();
			$(".page-button[id!='middle']").hide();
		};
		// alert('current_page_id = '+current_page_id); // Debug
	}

	// 左右键实现翻页：Debug用
	$(document).keydown(function(e){
		if($('*:focus').length == 0){
			if(event.keyCode == 37)	// 左
				prePage();
			if(event.keyCode == 39) // 右
				nextPage(true);	
		}
	})
</script>

</div>
</div>
</body>
</html>